import { useState, useEffect } from "react";
import { loadBannersAPI, loadCategoriesAPI } from "../services/banners";
import { dalImg } from "../utils/tools";

/**
 * 自定一个hooks
 * @returns
 */
export function useHomeData() {
  const [banners, setBanners] = useState([]);
  const [categories, setCategories] = useState([]);
  useEffect(() => {
    // 初始化的时候获取数据
    loadBannersAPI().then((res) => {
      setBanners(res.data.list);
    });
  }, []);

  return { banners, categories };
}
